#ifndef CHATWIDGET_H
#define CHATWIDGET_H

#include <QWidget>
#include <QVBoxLayout>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QAbstractSocket>
#include "ChatLogWidget.h"
#include "Network.h"
#include "GuiParameters.h"
#include "Chat.h"

#include <QDebug>

#define CHAT_ROWS 3

class ChatWidget : public QWidget {

    Q_OBJECT

public:
    explicit ChatWidget(QWidget *parent = 0);

signals:
    void responseSubmitted(Network::SocketMessage message);
    void chatSubmitted(QString chat);

public slots:
    void newConnection();
    void socketMessage(Network::SocketMessage message);
    void userRequest(Network::SocketMessage message);
    void chatMessage(QString chat);
    void confirmRespond(Network::SocketMessage message);
    void newGame();
    void playerWon(bool player);
    void changeConnectionStatus(Network::ConnectionStatus status);
    void socketError(QAbstractSocket::SocketError error);
    void socketDisconnected();

protected:
    bool eventFilter(QObject * object, QEvent * event);

private slots:
    void linkOnClick(const QUrl & link);

private:
    void createWidgets();
    void createLayouts();
    void connectSignalSlots();
    void initializeHash();
    void chatSubmit();

    ChatLogWidget * chatLog;
    QPlainTextEdit * chatInput;

    QHash<QString, Network::SocketMessage> linkMessageMap;

};

#endif // CHATWIDGET_H
